declare
fun {NewDictionary} leaf end
fun {Put Ds Key Value}
   % ... similar to Insert
end
fun {CondGet Ds Key Default}
   % ... similar to Lookup
end
fun {Domain Ds}
   proc {DomainD Ds ?S1 Sn}
      case Ds
      of leaf then
         S1=Sn
      [] tree(K _ L R) then S2 S3 in
         {DomainD L S1 S2}
         S2=K|S3
         {DomainD R S3 Sn}
      end
   end D
in
   {DomainD Ds D nil} D
end
